package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.base.app.req.*;
import com.sg.entity.OmsVirtualOrg;
import com.sg.service.base.app.MOmsVirtualOrgService;
import com.wicket.okrapp.common.annotations.BanAuto;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsVirtualOrgMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsVirtualOrgServiceImpl
        extends ServiceImpl<OmsVirtualOrgMapper, OmsVirtualOrg>
        implements MOmsVirtualOrgService {

    @Autowired
    OmsVirtualOrgMapper omsVirtualOrgMapper;

    /**
     * 3-6-01新增虚拟组织[2352]
     * gen by moon at 1/4/2023, 7:08:54 PM
     */
    @Trace(operationName = "3-6-01新增虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addVirtualOrg(OmsVirtualOrg omsVirtualOrg) {
        omsVirtualOrg.setVirtualOrgId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsVirtualOrg.setBatchEndTime(CommonFunctionHelper.getFutureTime());//FUTURE_CURRENT_TIME
        omsVirtualOrg.setIsUpdate("TRUE");
        omsVirtualOrg.setUpdateStatus("NEW");
        omsVirtualOrg.setIsEditing("TRUE");
        omsVirtualOrg.setArchivngType("NOT_ARCHIVE");
        omsVirtualOrg.setIsArchive("FALSE");
        omsVirtualOrg.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsVirtualOrg.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsVirtualOrg.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsVirtualOrg.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsVirtualOrg.setIsValid("FALSE");
        omsVirtualOrg.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsVirtualOrg.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsVirtualOrg)) {
            return omsVirtualOrg.getVirtualOrgId();
        } else {
            return "-1";
        }

    }

    /**
     * 3-6-01批量查询虚拟组织[3111]
     * gen by moon at 10/15/2022, 10:03:32 PM
     */
    @Trace(operationName = "3-6-01批量查询虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsVirtualOrg> batchQueryVirtualOrg(BatchQueryVirtualOrgReq reqDto) {

        try {
            QueryWrapper<OmsVirtualOrg> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if (reqDto.getVirtualOrgList() == null || reqDto.getVirtualOrgList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("entity_id", reqDto.getVirtualOrgList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsVirtualOrg.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsVirtualOrg.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsVirtualOrg.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsVirtualOrg>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-6-01查询虚拟组织[3139]
     * gen by moon at 1/26/2024, 1:00:14 AM
     */
    @Trace(operationName = "3-6-01查询虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsVirtualOrg queryVirtualOrgDetail(QueryVirtualOrgDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<OmsVirtualOrg> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsVirtualOrg> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsVirtualOrg retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-6-01删除虚拟组织[3208]
     * gen by moon at 10/15/2022, 10:03:38 PM
     */
    @Trace(operationName = "3-6-01删除虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteVirtualOrg(String virtualOrgId) {

        return super.removeById(virtualOrgId);
    }

    /**
     * 3-6-01查询虚拟组织列表[3681]
     * gen by moon at 10/15/2022, 10:03:40 PM
     */
    @Trace(operationName = "3-6-01查询虚拟组织列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsVirtualOrg> queryVirtualOrgList(QueryVirtualOrgListReq reqDto) {

        try {
            QueryWrapper<OmsVirtualOrg> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsVirtualOrg.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsVirtualOrg.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsVirtualOrg.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsVirtualOrg>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-6-01批量改虚拟组织[3682]
     * gen by moon at 10/15/2022, 10:03:42 PM
     */
    @Trace(operationName = "3-6-01批量改虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateVirtualOrg(List<OmsVirtualOrg> omsVirtualOrg) {

        if (omsVirtualOrg == null || omsVirtualOrg.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsVirtualOrg);

    }

    /**
     * 3-6-01批量删虚拟组织[3683]
     * gen by moon at 10/15/2022, 10:03:43 PM
     */
    @Trace(operationName = "3-6-01批量删虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteVirtualOrg(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * 3-6-01构造虚拟组织验证数据[4241]
     * gen by moon at 10/15/2022, 10:03:43 PM
     */
    @Trace(operationName = "3-6-01构造虚拟组织验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String buildVirtualOrg(OmsVirtualOrg omsVirtualOrg) {
        omsVirtualOrg.setVirtualOrgId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsVirtualOrg.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsVirtualOrg.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsVirtualOrg.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsVirtualOrg.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        omsVirtualOrg.setIsValid("FALSE");
        omsVirtualOrg.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsVirtualOrg.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsVirtualOrg)) {
            return omsVirtualOrg.getVirtualOrgId();
        } else {
            return "-1";
        }

    }

    /**
     * M3-6-01构造单条虚拟组织验证数据[4274]
     * gen by moon at 10/15/2022, 10:03:44 PM
     */
    @Trace(operationName = "M3-6-01构造单条虚拟组织验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String buildSingleVirtualOrg(OmsVirtualOrg omsVirtualOrg) {
        omsVirtualOrg.setVirtualOrgId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsVirtualOrg.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsVirtualOrg.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsVirtualOrg.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsVirtualOrg.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        omsVirtualOrg.setIsValid("FALSE");
        omsVirtualOrg.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsVirtualOrg.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsVirtualOrg)) {
            return omsVirtualOrg.getVirtualOrgId();
        } else {
            return "-1";
        }

    }

    /**
     * M3-6-01删除单条虚拟组织[4419]
     * gen by moon at 10/15/2022, 10:03:45 PM
     */
    @Trace(operationName = "M3-6-01删除单条虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteSingleVirtualOrg(String virtualOrgId) {

        return super.removeById(virtualOrgId);
    }

    /**
     * M3-6-01查询单条虚拟组织详情[4439]
     * gen by moon at 3/30/2023, 12:39:12 PM
     */
    @Trace(operationName = "M3-6-01查询单条虚拟组织详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsVirtualOrg querySingleVirtualOrgDetail(QuerySingleVirtualOrgDetailReq reqDto) {

        try {

            QueryWrapper<OmsVirtualOrg> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsVirtualOrg> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsVirtualOrg retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-6-01查虚拟组织（悬停）[6372]
     * gen by moon at 4/28/2023, 12:36:25 AM
     */
    @Trace(operationName = "3-6-01查虚拟组织（悬停）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    @BanAuto
    public List<OmsVirtualOrg> queryVirtualOrgHoverDetail(QueryVirtualOrgHoverDetailReq reqDto) {
        try {
            long count = 500;
            while (true) {
                if (count == 0) {
                    break;
                }
                reqDto.setIsValid("FALSE");
                QueryWrapper<OmsVirtualOrg> queryWrapper = new QueryWrapper<>();
                Map<String, Object> fieldInfoMap = null;
                fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
                CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
                queryWrapper.orderByDesc("create_time");
                if (super.list(queryWrapper) != null && super.list(queryWrapper).size() > 0) {
                    List<OmsVirtualOrg> retData = new ArrayList<>();
                    retData.add(super.list(queryWrapper).get(0));
                    return retData;
                }
                count--;
                Thread.sleep(10);
            }
            throw new BizException("-1", false);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }

    }

    /**
     * 3-06-01修改虚拟组织[7340]
     * gen by moon at 12/11/2023, 11:05:16 AM
     */
    @Trace(operationName = "3-06-01修改虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateVirtualOrg(OmsVirtualOrg omsVirtualOrg) {
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsVirtualOrg.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        return super.updateById(omsVirtualOrg);
    }

    /**
     * 3-6-01新增无批次虚拟组织[7819]
     * gen by moon at 11/9/2023, 10:14:58 PM
     */
    @Trace(operationName = "3-6-01新增无批次虚拟组织")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addNoBatchVirtualOrg(OmsVirtualOrg omsVirtualOrg) {
        omsVirtualOrg.setVirtualOrgId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsVirtualOrg.setIsArchive("FALSE");
        omsVirtualOrg.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsVirtualOrg.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        omsVirtualOrg.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsVirtualOrg.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsVirtualOrg != null && omsVirtualOrg.getSubjectLifeCycle() != null && omsVirtualOrg.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsVirtualOrg.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        omsVirtualOrg.setIsValid("FALSE");
        omsVirtualOrg.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsVirtualOrg.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsVirtualOrg)) {
            return omsVirtualOrg.getVirtualOrgId();
        } else {
            return "-1";
        }

    }
}
